package com.xinkao.enrollment;

import com.xinkao.enrollment.migration.Migrations;
import org.springframework.beans.BeansException;
import org.springframework.boot.CommandLineRunner;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Component;

@Component
public class SystemCommandLineRunner implements ApplicationContextAware, CommandLineRunner {

    private ApplicationContext appContext;

    @Override
    public void run(String... args) throws Exception {
        Migrations.migrate(appContext);
    }

    @Override
    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
        this.appContext = applicationContext;
    }

}
